<?php
/**
 * Fake4
 * @copyright   Copyright(c) 2024-2034
 * @author      tianjie <527707665@qq.com>
 * @link        http://www.tinphp.com/
 */

namespace app\middleware;

use tian\MiddlewareInterface;
use tian\Response;
use tian\Request;

class LogMiddleware implements MiddlewareInterface
{
    public function handle(Request $request, $next): Response
    {
        //日志记录中间件
        $method = $request->method();
        $controllerClass = $request->controllerClass();
        $action = $request->action();
        $content = $request->getContent();

        $body = "[request]----[" . $method . "][" . $controllerClass . "][" . $action . "][content:" . json_encode($content) . "]";
        setLog($body);

        return $next($request);
    }
}
